package com.yh.util;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.LinkedList;
import java.util.List;

public class ByteStream {
    static public List<Integer> read(File file){
        List<Integer> list = new LinkedList<>();
        try (FileInputStream fis = new FileInputStream(file)){
            int result = -1;
            while(true){
                result = fis.read();
                if (result==-1){
                    break;
                }
                list.add(result);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return list;
    }
    static public void Write(String path,List<Integer> content){
        try (FileOutputStream fos = new FileOutputStream(path)){
            for (Integer integer : content){
                fos.write(integer);
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
